home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / BKISSSRC.ZIP / CREDITS / DRAWSTRX.INC < prev    next >
Encoding:
Text File  |  1994-02-13  |  5.4 KB  |  96 lines

  1. ;this module is a slightly modified version of Patch's original routine
  2. ;this adds in a table to translate each column of the text vertically
  3.  
  4. TransparentText = 1     ;set to 0 to draw backgrounds of letters
  5. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  6. ; int far Draw_String(byte far *fontdata, byte far *string,
  7. ;                  word xskip, word pageoffs);
  8. ;
  9. PROC            Draw_String far
  10.                 push bp                         ;\ set up the stack frame
  11.                 mov bp,sp                       ;/
  12.  
  13.                 mov [@@PlaneNum],1102h          ;start at plane 0
  14.                 mov [@@ColumnNum],0             ;start at screen column 0
  15.  
  16.                 lgs si,[dword bp + 6]           ;GS:SI ==> start of fontdata
  17.                 mov es,[VGASeg]                 ;\ ES:DI ==> video offset
  18.                 mov di,[bp + 16]                ;/
  19.                 mov cx,[word bp + 14]           ;number of columns to skip
  20.                 lfs bp,[dword bp + 10]          ;FS:BP ==> string
  21.  
  22. @@SkipForward:  movzx bx,[byte fs:bp]           ;BX = next letter
  23.                 shl bx,1                        ;*2 = word sized
  24.                 mov [@@Save],si                 ;save our font pointer
  25.                 add si,[word 3+si+bx]           ;skip to the character's data
  26.                 movzx ax,[byte si+1]            ;AX = width of character
  27.                 cmp cx,ax                       ;
  28.                 jb @@StartWork                  ;
  29.                 sub cx,ax                       ;
  30.                 mov si,[@@Save]                 ;restore our font pointer
  31.                 inc bp                          ;next letter in message
  32.                 cmp [byte fs:bp],0              ;\ loop until we reach
  33.                 jne @@SkipForward               ;/ a null
  34.                 mov ax,-1                       ;say we've reached the end
  35.                 jmp @@Quit                      ;quit
  36. @@StartWork:    mov al,[byte si+2]              ;\ AX = height of character *
  37.                 mul cl                          ;/      columns to skip
  38.                 mov bh,[byte si+1]              ;BH = width of character
  39.                 mov bl,[byte si+2]              ;BL = height of character
  40.                 add si,3                        ;skip to start of data
  41.                 add si,ax                       ;skip past part off screen
  42.                 sub bh,cl                       ;set width to part on screen
  43.                 mov cx,bx                       ;store width/height in CH/CL
  44.                 jmp @@NextColumn                ;get working
  45.  
  46. @@NextLetter:   movzx bx,[byte fs:bp]           ;load letter from message
  47.                 shl bx,1                        ;*2 = word sized
  48.                 jz @@NoErrorQuit                ;quit if we reach a null
  49.                 mov [@@Save],si                 ;save font pointer
  50.                 add si,[word 3+si+bx]           ;point to spot in font file
  51.  
  52.                 mov ch,[byte si+1]              ;get X size
  53.                 mov cl,[byte si+2]              ;get Y size
  54.                 jcxz @@SkipChar                 ;skip if character is undefined
  55.                 add si,3                        ;point to start of data
  56.  
  57. @@NextColumn:   mov dx,03C4h                    ;\
  58.                 mov ax,[@@PlaneNum]             ; > set the write plane
  59.                 out dx,ax                       ;/
  60.                 mov dx,di                       ;save video pointer
  61.                 mov bx,[@@ColumnNum]            ;\
  62.                 shl bx,1                        ; > subtract row offset
  63.                 add di,[HeartPath+bx]           ;/
  64.                 mov bl,cl                       ;BL = height of character
  65. @@ColumnLoop:   mov al,[byte gs:si]             ;\
  66.                 inc si                          ; \
  67.                 if TransparentText ne 0         ;  \
  68.                     or al,al                    ;   \
  69.                     jz @@DontPlot               ;    \ draw a single column
  70.                 endif                           ;    /
  71.                 mov [byte es:di],al             ;   /
  72. @@DontPlot:     add di,[ModeXLogWidth]          ;  /
  73.                 dec bl                          ; /
  74.                 jnz @@ColumnLoop                ;/
  75.  
  76.                 mov di,dx                       ;restore video pointer
  77.                 rol [byte @@PlaneNum+1],1       ;go to next plane
  78.                 adc di,0                        ;move to next byte if needed
  79.                 inc [@@ColumnNum]               ;go to next column
  80.                 cmp [@@ColumnNum],ScreenWidth   ;\ quit if we've filled
  81.                 jae @@NoErrorQuit               ;/ the width of the screen
  82.                 dec ch                          ;\ loop until all columns in
  83.                 jnz @@NextColumn                ;/ character are done
  84. @@SkipChar:     mov si,[@@Save]                 ;restore our font pointer
  85.                 inc bp                          ;next letter in message
  86.                 jmp @@NextLetter                ;do the next letter
  87.  
  88. @@NoErrorQuit:  xor ax,ax                       ;signal no error
  89. @@Quit:         pop bp                          ;restore the stack frame
  90.                 ret                             ;return
  91. @@ColumnNum     dw ?
  92. @@PlaneNum      dw ?
  93. @@Save          dw ?
  94. ENDP            Draw_String
  95. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  96.